package com.client.service.impl;

import com.client.dto.GoodsAndLanguageDto;
import com.client.mapper.FlowerOrderMapper;
import com.client.pojo.FlowerOrder;
import com.client.service.FlowerOrderService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 晚云
 * @since 2023-09-12
 */
@Service
public class FlowerOrderServiceImpl extends ServiceImpl<FlowerOrderMapper, FlowerOrder> implements FlowerOrderService {

    @Autowired
    private FlowerOrderMapper flowerOrderMapper;

    /**
     * 插入订单
     *
     * @param flowerOrders
     * @return
     */
    @Override
    public boolean insertOrder(List<FlowerOrder> flowerOrders) {
        boolean flag = flowerOrderMapper.insertList(flowerOrders);
        return flag;
    }

    /**
     * 查询用户的订单
     *
     * @param userId
     * @return
     */
    @Override
    public List<FlowerOrder> order_select_List(String userId) {
        List<FlowerOrder> list = flowerOrderMapper.order_select_List(userId);
        return list;
    }

    /**
     * 根据用户id和商品id查询订单
     *
     * @param userId
     * @param goodsId
     * @return
     */
    @Override
    public List<FlowerOrder> selectAndCount(String userId, String goodsId) {
        List<FlowerOrder> flowerOrders = flowerOrderMapper.selectAndCount(userId,goodsId);
        return flowerOrders;
    }

    @Override
    public boolean saveOrder(GoodsAndLanguageDto dto, String orderId) {
        boolean flag = flowerOrderMapper.saveOrder(dto,orderId);
        return flag;
    }
}
